﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RecipeRecommender
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();

            cLoader = new CCaseLoader();
            //cuisine
            comboBox2.Items.Add("");
            comboBox2.Items.Add("Western");
            comboBox2.Items.Add("Chinese");
            comboBox2.Items.Add("Vietnamese");
            comboBox2.Items.Add("Indonesian");
            comboBox2.Items.Add("Indian");
            //


            //meal type
            comboBox3.Items.Add("");
            comboBox3.Items.Add("Starter");
            comboBox3.Items.Add("Desert");
            comboBox3.Items.Add("Main");

            //


            //cooking method

            comboBox4.Items.Add("");
            comboBox4.Items.Add("Soup");
            comboBox4.Items.Add("Steamed");
            comboBox4.Items.Add("Grilled");
            comboBox4.Items.Add("Mixed");
            comboBox4.Items.Add("Fried");
            //

            //spicy
            comboBox5.Items.Add("");
            comboBox5.Items.Add("Yes");
            comboBox5.Items.Add("No");
            //

            //halal
            comboBox6.Items.Add("");
            comboBox6.Items.Add("Yes");
            comboBox6.Items.Add("No");
            //

            //healthy
            comboBox7.Items.Add("");
            comboBox7.Items.Add("Yes");
            comboBox7.Items.Add("No");

            //

            //vegetarian

            comboBox8.Items.Add("");
            comboBox8.Items.Add("Yes");
            comboBox8.Items.Add("No");



            //included ingredients
            foreach (CIngredient cIng in cLoader.ingredientList)
            {
                comboBox1.Items.Add(cIng.getString());
            }
            
            //


            //excluded ingredients
            foreach (CIngredient cIng2 in cLoader.ingredientList)
            {
                comboBox9.Items.Add(cIng2.getString());
            }

            cSelectedList = new List<CIngredient>();
            cExcludedList = new List<CIngredient>();
            //cList = new List<CIngredient>();
            //cList.Add(new CSpinach());
            //cList.Add(new CVegetable());
            //cList.Add(new CCabbage());
            //cList.Add(new CMeat());
            //cList.Add(new CChicken());
            //cList.Add(new CBeef());
            //cList.Add(new CPork());

            

            //foreach(CIngredient cIng in cList)
            //{
            //    //String strText = "";
            //    //strText+= "the type is " +  cIng.GetType()+"\n";
            //    //listBox1.Items.Add(strText);
            //    comboBox1.Items.Add(cIng.getString());
            //}

            //CVegetable cVeg = new CVegetable();

            //bool bType = object.ReferenceEquals(cVeg.GetType(), cList[0].GetType());
            //if (bType)
            //{
            //    listBox1.Items.Add("the references are equal");
            //}
            //Type t = cList[0].GetType();

            //bType = object.ReferenceEquals(cVeg.GetType(),t.BaseType);
            //if (bType)
            //{
            //    //listBox1.Items.Add("the references are base type related");
            //} 
        }

        

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            CIngredient cIng = cLoader.ingredientList[comboBox1.SelectedIndex];
            cSelectedList.Add(cIng);
            listBox1.Items.Add(cIng.getString());

        }

        private void find_now_click(object sender, EventArgs e)
        {
            CRecipe cRecipeQuery = new CRecipe();

            if (comboBox2.SelectedIndex != -1)
            {
                cRecipeQuery.cuisine = comboBox2.SelectedIndex;
            }
            if (comboBox3.SelectedIndex != -1)
            {
                cRecipeQuery.mealType = comboBox3.SelectedIndex;
            }
            if (comboBox4.SelectedIndex != -1)
            {
                cRecipeQuery.cookingMethod = comboBox4.SelectedIndex;
            }

            if (comboBox5.SelectedIndex != -1)
            {
                cRecipeQuery.spicy = comboBox5.SelectedIndex;
            }

            if (comboBox6.SelectedIndex != -1)
            {
                cRecipeQuery.halal = comboBox6.SelectedIndex;
            }

            if (comboBox7.SelectedIndex != -1)
            {
                cRecipeQuery.healthy = comboBox7.SelectedIndex;
            }

            if (comboBox8.SelectedIndex != -1)
            {
                cRecipeQuery.vegetarian = comboBox8.SelectedIndex;
            }

            cRecipeQuery.ingredients = cSelectedList;
            cRecipeQuery.excludedIngredients = cExcludedList;

            List<CRecipe> cRelevant = cLoader.getRelevantCases(cRecipeQuery);

            Form2 form2 = new Form2();
            //form2.ShowRecipeList(cRelevant);
            form2.Show();
            foreach (CRecipe cRec in cRelevant)
            {
                //form2.AddString(cRec.name + "\n");
                //form2.AddString("Similarity: " + cRec.Similarity + "\n");
                //form2.AddString("\n");
                //form2.ShowRecipe(cRec);
                form2.AddString(cRec.getRecipeString());
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            cSelectedList.Clear();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            cExcludedList.Clear();
            listBox2.Items.Clear();
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void comboBox9_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            CIngredient cIng2 = cLoader.ingredientList[comboBox9.SelectedIndex];

            cExcludedList.Add(cIng2);
            listBox2.Items.Add(cIng2.getString());
        }
    }
}
